<?php

class Components_ajax extends Admin_Controller {

	function __construct()
	{
		parent::__construct();	
		$this->sSkinFile = 'ajax';
	}
	
	public function index()
	{
		return null;
	}
	
	
	
	public function save_component()
	{
		$iComponentId = $this->input->post('component_id', true, 0);
		$sComponentName = $this->input->post('component_name', true, '');
		$sComponent = $this->input->post('component', true, '');
		
		$this->load->model('db/site_components', 'site_components');
		
		if($iComponentId > 0)
		{
			$this->site_components->component_id = $iComponentId;
		}
		
		$this->site_components->component_name = $sComponentName;
		$this->site_components->component = $sComponent;
		
		$iComponentId = $this->site_components->save(false);
		
		$data['json_encode'] = array('iComponentId' => $iComponentId);
		
		$this->load->view('php_json_encode', $data);
	}
	
}

?>